/*
 *  Author: Sinclair Ross
 *  Date: 29/04/2014
 *  Description: Tile base-class - implements standard tile members and methods
 *
 */

package com.forbiddendesert.tiles;

import java.util.Vector;

import android.content.Context;
import android.graphics.Bitmap;
import android.util.Log;

import com.example.forbiddendesert.R;
import com.forbiddendesert.actions.Action;
import com.forbiddendesert.artefacts.Artefact;
import com.forbiddendesert.characters.Character;
import com.forbiddendesert.logic.GameObject;

public abstract class Tile extends GameObject
{
	int mSandCount;
	
	boolean mExcavated;
	boolean mRespite;
	boolean mInteractiveBeyondExcavation;
	
	Bitmap mExcavatedBitmap;
	
	Action mTileAction;
	
	Vector<Action> mAvailableActions;
	Vector<Character> mCharactersOnTile;
	Vector<Artefact> mArtefactsOnTile;
	
	// Initialise the tile
	public Tile(Context context) 
	{
		super(context);
		
		// Update the tiles destination rectangle
		updateDestinationRectangle();
		
		// Write debug log to the console
		Log.i("DEBUG GameThread", "updated source rectangle"); //set debug log
	
		mSandCount = 0;
		mExcavated = false;
		mRespite = false;
		mInteractiveBeyondExcavation = false;
		
		mBitmap = loadBitmap(context.getResources(),R.drawable.desert);
		mExcavatedBitmap = null;
		mTileAction = null;
		
		mAvailableActions = new Vector<Action>();
		mCharactersOnTile = new Vector<Character>();
		mArtefactsOnTile = new Vector<Artefact>();
	
	}
	
	// What happens upon excavation of this tile.
	// Must be implemented by subclass even if nothing happens
	public abstract void excavateTile(Character character);
	
	// What happens when a player interacts with this tile.
	// Must be implemented by subclass even if nothing happens.
	public abstract void interactWithTile(Character character);
	
	// Adds integer amount onto the total sand count for this tile.
	public void addSand(int amount)
	{
		mSandCount += amount;
	}
	
	// Removes integer amount from the total sand count for this tile.
	// Also prevents mSandCount for dipping bellow 0.
	public void removeSand(int amount)
	{
		mSandCount -= amount;
		
		if(mSandCount < 0)
			mSandCount = 0;
	}
	
	// Adds a reference to a character to this tile representing a character that
	// is standing on this tile.
	public void addCharacterToTile(Character character)
	{
		mCharactersOnTile.add(character);
	}
	
	// Removes a reference to a character from this tile representing a character that
	// has left this tile.
	public void removeCharacterFromTile(Character character)
	{
		mCharactersOnTile.remove(character);
	}
	
	// Adds an action that the player can perform on this tile
	// to this tile.
	public void addAvailableAction(Action available)
	{
		mAvailableActions.add(available);
	}
	
	// Returns a reference to the vector containing the actions that can be
	// performed with this tile.
	public Vector<Action> getAvailableActions()
	{
		return mAvailableActions;
	}
	
	// Returns a reference to the vector containing all the characters that are
	// standing on this tile.
	public Vector<Character> getCharactersOnTile()
	{
		return mCharactersOnTile;
	}
	
	// Returns a reference to all the artefacts that reside on this tile.
	public Vector<Artefact> getArtefactsOnTile()
	{
		return mArtefactsOnTile;
	}
	
	public int getSandCount()
	{
		return mSandCount;
	}
}







































